//
//  ViewController.m
//  ZTEOnlineDoc
//
//  Created by 万伟琦 on 2018/9/6.
//  Copyright © 2018年 万伟琦. All rights reserved.
//

#import "ViewController.h"
#import "ZODPreviewController.h"
#import "ZODAttInfo.h"
#import "ZODHTTPManager.h"
#import "ZODAESCipher.h"
#import "ZTEOnlineDoc.h"
#import "ZODFileInfo.h"
#import "ZTEOnlineRead/ZODOnlineDocConfiguration.h"
#import "ZODNetworkRequest.h"

@interface ViewController ()

@property (nonatomic) ZTEOnlineDoc* doc;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.1
    
    

    
    
}

- (IBAction)push:(id)sender {
    
//    ZODOnlineDocConfiguration *docConfig = [ZODOnlineDocConfiguration configureWithPreviewBaseUrl:@"http://10.5.172.76/Mapi/UpLoadFileJSONService/service.dssm" sysCode:@"ZMAIL" userNo:@"6092002445"];
    
//    UIViewController *vc = [[ZTEOnlineDoc sharedInstance] getPreviewControllerWithUserNo:@"6396000623" waterText:@"12313" fileMD5:@"000100005b289e2f38a0092c00002" fileName:@"Chrysanthemum.jpg" fileURL:@"http://10.5.172.76/Mapi/UpLoadFileJSONService/service.dssm?CT=0&PT=0&UNO=6396000623&ID=000100005b289e2f38a0092c00002&N=Chrysanthemum.jpg&U=null&S=879394&I=0&T=2&D=&Token=00012af9000148145b98e730KJut#S5QbmjerjvMqt386sSWv"];
    
    
    
//    UIViewController *vc = [doc getPreviewControllerWithWaterText:@"123" fileMD5:@"000100005b289e2f38a0092c00002" fileName:@"Chrysanthemum.jpg" fileURL:@"http://10.5.172.76/Mapi/UpLoadFileJSONService/service.dssm?CT=0&PT=0&UNO=6396000623&ID=000100005b289e2f38a0092c00002&N=Chrysanthemum.jpg&U=null&S=879394&I=0&T=2&D=&Token=00012af9000148145b98e730KJut#S5QbmjerjvMqt386sSWv"];
//    UIViewController *vc = [self.doc getPreviewControllerWithWaterText:@"123" fileMD5:@"00010000004f3e7307270ef200001" fileName:@"需求20170801.doc" fileURL:@"http://10.41.252.138/Mapi/UpLoadFileJSONService/service.dssm?CT=2&PT=0&UNO=6092002445&ID=00010000004f3e7307270ef200001&RID=&N=%25E9%259C%2580%25E6%25B1%258220170801.doc&U=&S=3246080&I=0&T=1&D=00010002bc91a1983178cb8400002&Token=00012af90000004f5b9f6577l6jE%2523EV0nXC4ofzsMHpKFImhW"];
    
    UIViewController *vc = [self.doc getPreviewControllerWithAttInfo:[self createAtt]];
    
    [self.navigationController pushViewController:vc animated:YES];
}



#pragma mark - Test
- (IBAction)auth:(id)sender {
    
    ZODFileInfo *fileInfo = [[ZODFileInfo alloc] init];
//    fileInfo.md5 = @"000100005b289e2f38a0092c00002";
//    fileInfo.fileName = @"Chrysanthemum.jpg";
//    fileInfo.fileUrl = @"http://10.5.172.76/Mapi/UpLoadFileJSONService/service.dssm?CT=0&PT=0&UNO=6396000623&ID=000100005b289e2f38a0092c00002&N=Chrysanthemum.jpg&U=null&S=879394&I=0&T=2&D=&Token=00012af9000148145b98e730KJut#S5QbmjerjvMqt386sSWv";
//    fileInfo.page = @"-1";
    
    fileInfo.md5 = @"00010000004f3e7307270ef200001";
    fileInfo.fileName = @"需求20170801.doc";
    fileInfo.fileUrl = @"http://10.41.252.138/Mapi/UpLoadFileJSONService/service.dssm?CT=2&PT=0&UNO=6092002445&ID=00010000004f3e7307270ef200001&RID=&N=%25E9%259C%2580%25E6%25B1%258220170801.doc&U=&S=3246080&I=0&T=1&D=00010002bc91a1983178cb8400002&Token=00012af90000004f5b9f6577l6jE%2523EV0nXC4ofzsMHpKFImhW";
    fileInfo.page = @"-1";
    
//    NSString *baseUrlStr = @"http://10.5.172.103/api/prebatchconvert";
    
//    [self.doc preConvertWithFiles:@[fileInfo] sysCode:@"ZMAIL" userNo:@"6092002445"];
    
//    [self.doc preConvertWithFiles:@[fileInfo]];
    
    
    [ZODNetworkRequest requestAuthWithAttInfo:[self createAtt] success:^{
        
    } failure:^(NSError * _Nonnull error, NSString * _Nonnull errorCode) {
        
    }];
    
}

- (ZODAttInfo *)createAtt {
    __unused ZODAttInfo *att = [[ZODAttInfo alloc] init];
//    att.ID = @"00010000004f3e7307270ef200001";
//    att.RID = @"";
//    att.N = @"%25E9%259C%2580%25E6%25B1%258220170801.doc";
//    att.U = @"";
//    att.S = @"3246080";
//    att.I = @"0";
//    att.T = @"1";
//    att.D = @"00010002bc91a1983178cb8400002";
//    att.VT = @"2";
//    att.CT = @"2";
    
    att.ID = @"000100005b289e2f38a0092c00002";
    att.RID = @"";
    att.N = @"Chrysanthemum.jpg";
    att.U = @"";
    att.S = @"879394";
    att.I = @"0";
    att.T = @"2";
    att.D = @"";
    att.VT = @"2";
    att.CT = @"2";
    
    return att;
    
}

//预加载
- (IBAction)networkRequest:(id)sender {
    ZODAttInfo *att = [self createAtt];
    [self.doc preConvertWithFiles:@[att]];
    
}

@end
